package br.univali.compiladores.maquinavirtual;

import java.util.Map;

import javax.swing.table.DefaultTableModel;

import br.univali.compiladores.compilador.semantico.InstrucaoMaquinaVirtual;

/**
 *
 * @author Daniel
 */
public class InstrucoesFrame extends javax.swing.JFrame {

    /**
	 * 
	 */
	private static final long serialVersionUID = -1902820309160856105L;
	private Map<Integer,InstrucaoMaquinaVirtual>  instrucoes;
	public Map<Integer,InstrucaoMaquinaVirtual> getInstrucoes() {
		return instrucoes;
	}




	/**
     * Creates new form Instrucoes
     */
    public InstrucoesFrame(Map<Integer, InstrucaoMaquinaVirtual> instrucoes) {
        initComponents();
        this.jTable1.setEnabled(false);
        Object[][] data = new Object[instrucoes.size()][];
        this.instrucoes = instrucoes;
        for(int i = 0; i < instrucoes.size(); i++){
        	
        	InstrucaoMaquinaVirtual instrucao = instrucoes.get(i + 1);
        	data[i] = new Object[]{i + 1,instrucao.getCodigo(), instrucao.getParametro()};
        }
        this.setTitle("Código objeto");
        
        this.jTable1.setModel(new DefaultTableModel(data, new String[]{"nº Instrução", "Código", "Parâmetro"}));
    }
    
    
    

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jScrollPane1.setViewportView(jTable1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>

    
    // Variables declaration - do not modify
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    // End of variables declaration
}
